package com.dlengine.framework.web.enums;

import com.dlengine.framework.web.constants.response.ResponseCodeSequence;
import com.dlengine.framework.web.base.response.BaseResponseCode;

/**
 * ResponseCode
 *
 * @author chentudong
 * @date 2024/1/15 15:12
 * @since 1.0
 */
public enum ResponseCode implements BaseResponseCode {
  /**
   * SUCCESS 操作成功
   */
  SUCCESS(ResponseCodeSequence.TRUE, ResponseCodeSequence.SUCCESS, "操作成功！"),

  /**
   * FAIL 操作失败
   */
  FAIL(ResponseCodeSequence.FALSE, ResponseCodeSequence.CODE_ERROR_POPUP, "操作失败！"),
  /**
   * MISSING_REQUEST_BODY Post请求中，body中没有传输数据！
   */
  MISSING_REQUEST_BODY(ResponseCodeSequence.FALSE, ResponseCodeSequence.COMMON,
      "Post请求中，body中没有传输数据！"),

  /**
   * SERVICE_CALL_ERROR 服务调用出错
   */
  SERVICE_CALL_ERROR(ResponseCodeSequence.FALSE, ResponseCodeSequence.SERVICE_CALL_ERROR, "微服务调用出错！"),

  /**
   * SERVER_ERROR 抱歉，系统繁忙，请稍后重试！
   */
  SERVER_ERROR(ResponseCodeSequence.FALSE, ResponseCodeSequence.CODE_ERROR_POPUP,
      "抱歉，系统繁忙，请稍后重试！"),

  SERVER_TIME_OUT(ResponseCodeSequence.FALSE, ResponseCodeSequence.CODE_ERROR_POPUP, "网络异常，请稍后重试！");


  /**
   * code
   */
  private Integer code;

  /**
   * 状态
   */
  private Boolean success;

  /**
   * 提示信息
   */
  private String message;

  ResponseCode(Boolean success, Integer code, String message) {
    this.code = code;
    this.success = success;
    this.message = message;
  }


  /**
   * success
   *
   * @return Boolean
   */
  @Override
  public Boolean success() {
    return this.success;
  }

  /**
   * code
   *
   * @return Integer
   */
  @Override
  public Integer code() {
    return this.code;
  }

  /**
   * message
   *
   * @return String
   */
  @Override
  public String message() {
    return this.message;
  }
}
